<?php

namespace app\admin\controller;

use app\admin\model\AdminUser;
use think\captcha\Captcha;
use think\Controller;
use think\facade\Request;
use think\facade\Session;


class Base extends Controller

{
    public $say="我是thinkphp";



    public function login(){
        $this->view->engine->layout(false);
        return $this->fetch("base/login");
    }

    public function checkLogin(){
        // 检测输入的验证码是否正确，$value为用户输入的验证码字符串
        $captcha = new Captcha();
        if( !$captcha->check(Request::param('captcha')))
        {
            // 验证失败
            $this->error("验证码错误","login");
            return;
        }
        $admin=AdminUser::where('username',Request::param('username'))->where('pass',md5(md5(Request::param('pass'))))->find();
        if($admin){
            Session::set("username",$admin->username);
            $this->redirect("index/managerList");
        }else{
            $this->error("用户名或密码错误","login");
        }
    }

    public function quit(){
        Session::delete('username');
        $this->redirect('login');
    }




}